/* DangKhoaWeb */
jQuery(document).ready(function(){
    jQuery('a').click(function(){
        //        if (jQuery(this).attr('href').indexOf('delete',1) != -1) {
        //            if (!confirm ('Are you sure you want to do this?')) {
        //                return false;
        //            }
        //        }
        if (jQuery(this).attr('href').indexOf('delete',1) != -1) {
            // e.preventDefault();
            var theHREF = $(this).attr("href");
            //$( "#dialog:ui-dialog" ).dialog( "destroy" );
            if (jQuery(this).attr('href').indexOf('deletecoursesession',1) != -1)
            {
             
                var myurl=jQuery(this).attr('href').replace("deletecoursesession","confirmdeletesession");
                $.post(myurl, function(data) {
                    $.blockUI({
                        theme:     true,
                        title:    'Please confirm to delete only this record or related group',
                        message:data
                    });
                    $('.blockOverlay').attr('title','Click to unblock').click($.unblockUI); 
                });
            
                return false;
            }
            else
            {
                $( "#dialog-confirm" ).dialog({
                    modal: true,
                    buttons: {
                        "Confirm deletion": function() {
                            window.location.href = theHREF;
                        },
                        Cancel: function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });
                $("#dialog-confirm").dialog("open");

                return false;
            }
        }
    });   

});
